# -*- coding: utf-8 -*-
# @Author : HaleShi
# @Time : 2023-04-12
# @File : hook脚本-密码.py

import frida
import sys

# 连接手机设备
rdev = frida.get_remote_device()

# Hook手机上的那个APP（app的包名字）
session = rdev.attach("油联合伙人")

scr = """
Java.perform(function () {

    // 包.类
    var LoginPresenter = Java.use("com.yltx.oil.partner.modules.login.presenter.LoginPresenter");
    var Md5 = Java.use("com.yltx.oil.partner.utils.Md5");

    // Hook，替换
    LoginPresenter.submitLogin.implementation = function(str,str2){
        console.log(str,str2);
        var res = this.submitLogin(str,str2);
        return res;
    }

    Md5.md5.implementation = function(str){
        var res = this.md5(str);

        console.log("明文",str);
        console.log("密文",res);
        return res;
    }

});
"""

script = session.create_script(scr)


def on_message(message, data):
    print(message, data)


script.on("message", on_message)
script.load()
sys.stdin.read()